package util;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;

public class URLUtil {

	public static String request(String str){
		try {
			URL url = new URL(str);
			URLConnection connection;
			connection = url.openConnection();
			String result = "";
			BufferedReader read = new BufferedReader(new InputStreamReader(connection.getInputStream(),"UTF-8"));
			String line;//循环读取
	        while ((line = read.readLine()) != null) {result += line;}
	        return result;
		} catch (MalformedURLException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return null;
	}
}
